#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "serverthread.h"
#include "clientthread.h"
#include "form.h"
#include <QTimer>
#include <QMap>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void dealNewConnection();
    void dealRecSigFileInfo(QString name,QString filePath,qint64 size,qint64 received_size);
    void dealSendSigFileInfo(QString name,qint64 received_size);
    void dealRecSigOver(QTcpSocket*,QString,bool);
    void dealSendSigOver(QString,bool);

private slots:
    void on_pushButton_clicked();

private:
    void serverInit();

    bool getReceiveFirst(QString);
    Form* getReceiveForm(QString);
    ServerThread* getServerThread(QTcpSocket*);


    Form* getSendForm(QString);
    ClientThread* getClientThread(QString);
private:
    Ui::Widget *ui;
    QTcpServer *m_qtcpServer;
    QMap<QString,Form*> m_mapReceive;
    QMap<QTcpSocket*,ServerThread*> m_mapTcpServer;
    bool m_recFlag;
    QList<QString> m_ListRecFirst;

    QMap<QString,Form*> m_mapSend;
    QMap<QString,ClientThread*> m_mapClient;
};
#endif // WIDGET_H
